<%@ Page Language="vb" AutoEventWireup="false" Inherits="Workflow.EditItem" CodeFile="EditItem.aspx.vb" Title="Add New Item" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD runat="server">
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultProjectScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <LINK href="../styles/styles.css?date=16may08" type="text/css" rel="stylesheet">
    <LINK href="../styles/datepickercontrol.css" type="text/css" rel="stylesheet">
    <script type="text/javascript"  src="../scripts/edititem.js"></script>
    <script type="text/javascript"  src="../scripts/datepickercontrol.js"></script>
        <link rel="Shortcut Icon" href="../images/favicon.ico" />
    <script>

        $("textarea").keydown(function (e) {
            if (e.keyCode === 9) { // tab was pressed
                // get caret position/selection
                var start = this.selectionStart;
                end = this.selectionEnd;

                var $this = $(this);

                // set textarea value to: text before caret + tab + text after caret
                $this.val($this.val().substring(0, start)
                        + "\t"
                        + $this.val().substring(end));

                // put caret at right position again
                this.selectionStart = this.selectionEnd = start + 1;

                // prevent the focus lose
                return false;
            }
        });
    </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server" enctype="multipart/form-data">

        <input type="hidden" id="DPC_TODAY_TEXT" value="today">
        <input type="hidden" id="DPC_BUTTON_TITLE" value="Open calendar...">
        <input type="hidden" id="DPC_MONTH_NAMES" value="['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']">
        <input type="hidden" id="DPC_DAY_NAMES" value="['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']">

      <span class="navigation">
        <asp:HyperLink ID="lnkBack" Runat="server" CssClass="navigation" NavigateUrl="ListItems.aspx">&lt;&lt; Back to Jobs List</asp:HyperLink>
				<asp:HyperLink ID="lnkNew" Runat=server CssClass=navigation NavigateUrl="~/pages/EditItem.aspx">New Job</asp:HyperLink>
				<asp:HyperLink ID="lnkUsers" Runat=server CssClass=navigation NavigateUrl="~/pages/EditUsers.aspx">Users</asp:HyperLink>
				<asp:HyperLink ID="lnkProjects" Runat=server CssClass=navigation NavigateUrl="~/pages/EditCategories.aspx">Projects</asp:HyperLink>
      </span>
      <br>
      <br>
      <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="top" width="50%">
            <h5><asp:Literal ID="litTitle" Runat="server">Add New Job</asp:Literal></h5>
            <table class="userControl">
              <tr id="rowStatus" runat="server">
                <td valign="top">
                  <h5>Status</h5>
                </td>
                <td>
                  <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                      <td>
                        <label><asp:Literal ID="litStatusName" runat="server" /></label>
                      </td>
                      <td align="right">
                        <asp:Button ID="btnStart" Runat="server" Text="Start >>" Visible="False" ToolTip="Change status to 'In-Progress'" />
                        
                        <asp:Button ID="btnStop" Runat="server" Text="<< Stop" Visible="False" ToolTip="Change status to 'Not-Started'" />
                        <asp:Button ID="btnFinish" Runat="server" Text="Finish >>" Visible="False" ToolTip="Change status to 'Completed'" />
                        
                        <asp:Button ID="btnOpen" Runat="server" Text="<< Open" Visible="False"  ToolTip="Change status back to 'In-Progress'" />
                      </td>
                    </tr>
                  </table>  
                </td>
              </tr>
              <tr>
                <td>
                  <h5>Project</h5>
                </td>
                <td>
                  <asp:DropDownList ID="ddCategory" Runat="server" DataTextField="CategoryName" DataValueField="CategoryId" />
                  <span onclick="return NewProject(hiddenProjectName)"><asp:ImageButton Tooltip="Add a new Project to the list" ID="btnAddProject" Runat="server" ImageUrl="../images/add.png" /></span> 
                  <input type="hidden" id="hiddenProjectName" runat="server" />
                </td>
              </tr>
              <tr>
                <td>
                  <h5>Title</h5>
                </td>
                <td>
                  <asp:TextBox ID="txtName" Runat="server" MaxLength="255" Width="450" />
                </td>
              </tr>
              <tr>
                <td valign="top">
                  <h5>Description</h5>
                </td>
                <td>
                  <asp:TextBox ID="txtDescription" Runat="server" TextMode="MultiLine" Rows="15" Width="450" Font-Name="Arial"
                    Font-Size="11px" />
                </td>
              </tr>
              <tr>
                <td>
                  <h5>Priority</h5>
                </td>
                <td>
                  <asp:RadioButtonList ID="rblPriority" Runat="server" RepeatDirection="Horizontal" DataTextField="PriorityName"
                    DataValueField="PriorityId" />
                </td>
              </tr>
              <tr>
                <td nowrap>
                  <h5>Estimate</h5>
                </td>
                <td>
                  <asp:TextBox ID="txtEstimate" Runat="server" style="TEXT-ALIGN:right" MaxLength="6" Width="80">1</asp:TextBox>
                  Hrs
                </td>
              </tr>
              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td nowrap>
                  <h5>Assigned To:</h5>
                </td>
                <td nowrap>
                  <asp:DropDownList ID="ddUserId" Runat="server" DataTextField="UserName" DataValueField="UserId"  />
                  <asp:DropDownList ID="ddUserId2" Runat="server" DataTextField="UserName" DataValueField="UserId"  />
                  <asp:DropDownList ID="ddUserId3" Runat="server" DataTextField="UserName" DataValueField="UserId" Visible=false  />
                  <asp:DropDownList ID="ddUserId4" Runat="server" DataTextField="UserName" DataValueField="UserId" Visible=false />
                </td>
              </tr>
              <tr id="rowCc" class="hidden">
                <td nowrap valign="top">
                  <h5>CC List</h5>
                </td>
                <td>
                  <span style="FONT-SIZE:10px">* Use CTRL Key to select multiple items<br>
                  </span>
                  <asp:ListBox ID="ddCc" Runat="server" Rows="5" DataTextField="UserName" DataValueField="UserId" SelectionMode="Multiple" />
                </td>
              </tr>
              <tr>
                <td>
                  <span onclick="return confirm('Delete this Job?')">
                    <asp:Button ID="btnDelete" Runat="server" Text="Delete" />
                  </span>
                </td>
                <td align="right">
                  <asp:CheckBox ID="chkSendEmail" Runat="server" Text="Send Email(s)" Checked="False" Font-Size="14px"
                    onclick="document.getElementById('rowCc').className= document.forms[0].chkSendEmail.checked?'visible':'hidden'" />
                  &nbsp;
                  <span onclick="var chk=document.forms[0].chkSendEmail; if (chk.checked) { chk.checked=confirm('Send Email(s)?'); }">
                    <asp:Button ID="btnSave" Runat="server" Text="Save Job" />
                  </span>
                </td>
              </tr>
            </table>
          </td>
          <td>&nbsp;</td>
          <td valign="top">
            <h5>Related Jobs</h5>
            <div class="userControl">
              <asp:DataGrid ID="dgIssues" Runat="server" AutoGenerateColumns="False" Width="100%" ShowHeader=False CellPadding=0 CellSpacing="0">
                <ItemStyle CssClass="odd" />
                <AlternatingItemStyle CssClass="even" />
                <HeaderStyle CssClass="head"  />
                <Columns>
                  <asp:HyperLinkColumn HeaderText="Name" DataTextField="ItemName" DataNavigateUrlField="ItemId" DataNavigateUrlFormatString="EditItem.aspx?itemId={0}"
                    Target="_blank" ItemStyle-Width="100%" HeaderStyle-Width="100%" />
                  <asp:TemplateColumn ItemStyle-HorizontalAlign="Right" ItemStyle-Width="0px">
                    <ItemTemplate>
                      <a onclick="return confirm('Delete this link?')" title="Delete Link To Job"
											href='?itemId=<%=Request("itemId")%>&deleteItemId=<%# DataBinder.Eval(Container.DataItem, "ItemId") %>'><img style="margin:2px;"  border=0 src="../images/delete.png"/></a>
									  </ItemTemplate>
                  </asp:TemplateColumn>
                </Columns>
              </asp:DataGrid>
              <table width="100%" cellpadding=0>
                <tr>
                  <td width="100%">
                    <input type="button" onclick="window.open('ListItems.aspx')" value="Browse Jobs...">
                  </td>
                  <td nowrap>
                    <h5>Job Id:
                      <asp:TextBox ID="txtIssue" Runat="server" Width="45px" style="TEXT-ALIGN:right" /></h5>
                  </td>
                  <td>
                    <asp:ImageButton ID="btnAdd" Runat="server" ToolTip="Add Linked Job" ImageUrl="../images/add.png"  />
                  </td>
                </tr>
              </table>
            </div>
            <br>
            <br>
            <h5>Attachments</h5>
            <div class="userControl">
              <asp:DataGrid ID="dgFiles" Runat="server" AutoGenerateColumns="False" ShowHeader=False CellPadding=0>
                <ItemStyle VerticalAlign="Top" CssClass="odd" />
                <AlternatingItemStyle VerticalAlign="Top" CssClass="even" />
                <HeaderStyle CssClass="head" />
                <Columns>
                  <asp:HyperLinkColumn HeaderText="Name" DataTextField="FileNameAndSize" DataNavigateUrlField="FileId"
                    DataNavigateUrlFormatString="GetFile.aspx?fileId={0}" Target="_blank" ItemStyle-Width="100%" HeaderStyle-Width="100%" />
                  <asp:TemplateColumn HeaderText="Delete" ItemStyle-HorizontalAlign="Right">
                    <ItemTemplate>
                      <a style=margin:0px;padding:0px; onclick="return confirm('Delete this file?')" title="Delete File"
												href='?itemId=<%=Request("itemId")%>&deleteFileId=<%# DataBinder.Eval(Container.DataItem, "FileId") %>'><img style="margin:2px;" border=0 src="../images/delete.png"/></a>
                    </ItemTemplate>
                  </asp:TemplateColumn>
                </Columns>
              </asp:DataGrid>
              <table width="100%">
                <tr>
                  <td width="100%">
                    <input type="file" name="file" style="WIDTH:100%">
                  </td>
                  <td>
                    <asp:ImageButton ID="btnUpload" Runat="server" Tooltip="Upload File" ImageUrl="../images/add.png"  />
                  </td>
                </tr>
              </table>
            </div>
            <br>
            <br>
            <h5>Comments</h5>
            <div class="userControl">
              <asp:DataGrid ID="dgComments" Runat="server" AutoGenerateColumns="False" ShowHeader=False CellPadding=0>
                <HeaderStyle CssClass="head" />
                <ItemStyle CssClass="odd" VerticalAlign="Top" />
                <AlternatingItemStyle CssClass="even" />
                <Columns>
                  <asp:TemplateColumn HeaderText="Date/User">
                    <ItemStyle Wrap="False" />
                    <ItemTemplate>
                      <%# CType(DataBinder.Eval(Container.DataItem, "CommentDate"), DateTime).ToString("dd MMM yyyy") %>
                      <br>
                      <%# DataBinder.Eval(Container.DataItem, "UserName") %>
                    </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:BoundColumn DataField="CommentBr" HeaderText="Comments" ItemStyle-Width="100%" HeaderStyle-Width="100%" />
                  <asp:TemplateColumn HeaderText="Delete">
                    <ItemTemplate>
                      <a style=margin:0px;padding:0px; onclick="return confirm('Delete this comment?')" title="Delete Comment"
												href='?itemId=<%=Request("itemId")%>&deleteCommentId=<%# DataBinder.Eval(Container.DataItem, "CommentId") %>'><img style="margin:2px;" border=0 src="../images/delete.png"/></a>
                    </ItemTemplate>
                  </asp:TemplateColumn>
                </Columns>
              </asp:DataGrid>
              <table width="100%">
                <tr>
                  <td width="100%">
                    <asp:TextBox ID="txtComments" Runat="server" Width="100%" TextMode="MultiLine" Rows="3" 
                       /><br>
                  </td>
                  <td valign="top">
                    <asp:ImageButton ID="btnAddComment" Runat="server" ToolTip="Add Comment" ImageUrl="../images/add.png"  /><br>
                  </td>
                </tr>
              </table>
            </div>
          </td>
        </tr>
      </table>
      <table cellpadding="0" cellspacing="0" style="MARGIN-TOP:20px" width="100%">
        <tr>
          <td style="CURSOR:hand" onclick="ToggleTable(this)" title="Click Show History">
            <img border="0" src="../images/minus.gif" style="DISPLAY:none;MARGIN:0px"> <img border="0" src="../images/plus.gif" style="MARGIN:0px">
          </td>
          <td nowrap>
            <h5 style="MARGIN:0px">&nbsp;History</h5>
          </td>
          <td width="100%">
          </td>
        </tr>
      </table>
      <asp:DataGrid ID="dgHistory" Runat="server" AutoGenerateColumns="False" CellPadding="3" CellSpacing="0"
        CssClass="userControl" STYLE="DISPLAY:none">
        <HeaderStyle Font-Bold="True" BackColor="#cccccc" Font-Size="14px" />
        <ItemStyle BackColor="#eeeeee" Font-Size="12px" VerticalAlign="Top" />
        <AlternatingItemStyle BackColor="#dddddd" />
        <Columns>
          <asp:BoundColumn DataField="HistoryDate" HeaderText="Date" DataFormatString="{0:dd MMM yyyy HH:mm:ss}" />
          <asp:BoundColumn DataField="UserName" HeaderText="User" />
          <asp:BoundColumn DataField="HistoryDescriptionBr" HeaderText="Changes" />
        </Columns>
      </asp:DataGrid>
      <a name="history">&nbsp;</a>
    </form>
  </body>
</HTML>
